package com.yxh.www.author.dto;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.util.Arrays;
import java.util.Set;
import java.util.TreeSet;

/**
 * <p>
 *  第三方账户Token信息
 * </p>
 *
 * @author yangxiaohui
 * @since 2020/5/14
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class SmAccountToken implements Serializable {
    private static final long serialVersionUID = 1L;
    /**
     * PK
     */
    private String accountId;
    /**
     * 账户名
     */
    private String accountName;
    /**
     * Token
     */
    private String token;
    /**
     * 放入可请求地址 - 精准匹配
     */
    private Set<String> apiPath;
    /**
     * 放入PathValue 模糊匹配地址
     */
    private Set<String> pathValueApiPath;
    /**
     * 应用可作用域集合
     */
    private Set<String> accountScopeIps;

    public SmAccountToken() {
    }

    public SmAccountToken(String accountId, String accountName, String token, Set<String> apiPath, Set<String> pathValueApiPath,String accountScopeIp) {
        this.accountId = accountId;
        this.accountName = accountName;
        this.token = token;
        this.apiPath = apiPath;
        this.pathValueApiPath = pathValueApiPath;
        if (accountScopeIp!=null){
            this.accountScopeIps=new TreeSet<String>(Arrays.asList(accountScopeIp.split(",")));
        }
    }
}
